<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
      <#include "/common/elibs.html">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
  </head>
  <script>var index;
  </script><body>
    <div class="x-body">
        <form class="layui-form">
            <input type="hidden" name="idxProAdmin" id="idxProAdmin" value="${id}"/>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    开始时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="beginTime" name="beginTime"
                           autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    结束时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="endTime" name="endTime"
                           autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    距离结束时间天数
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="differenceTime" name="differenceTime"
                           autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>客户名称
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="customerName" name="customerName" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" disabled >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>工单编号
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="workOrderNumber" name="workOrderNumber" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>方案类别
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="programmeType" name="programmeType" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>客户类型
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="customerType" name="customerType" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>用电地址
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="customerAddress" name="customerAddress" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  disabled >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>经度
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="longitude" name="longitude" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" disabled >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>纬度
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="latitude" name="latitude" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" disabled >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>海拔
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="altitude" name="altitude" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" disabled >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>客户分类
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="customerLevel" name="customerLevel" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>负荷类别
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="loadType" name="loadType" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>行业类别
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="industryType" name="industryType" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>供电总容量
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="electricTotalCapacity" name="electricTotalCapacity" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" disabled >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>供电电压
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="powerSupplyVoltage" name="powerSupplyVoltage" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>线路敷设
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="layingLines" name="layingLines" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>工程类别
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="engineeringType" name="engineeringType" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>是否设计
                </label>
                <div class="layui-input-inline">
                    <input type="radio" name="isDesign"
                           lay-verify="otherReq" lay-filter="isDesign"  value="1" title="是">
                    <input type="radio" name="isDesign"
                           lay-verify="otherReq" lay-filter="isDesign"  value="0" title="否" >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>用电类别
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="electricityType" name="electricityType" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>计量方式
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="meteringType" name="meteringType" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>计算变损
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="calculationLoss" name="calculationLoss" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>计算线损
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="calculationLineLoss" name="calculationLineLoss" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>采控配置
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="productionControl" name="productionControl" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>联系人
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="customerContacts" name="customerContacts" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" disabled >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>联系电话
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="customerPhone" name="customerPhone" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" disabled >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>运行管理单位
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="operatingUnit" name="operatingUnit" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>是否涉及变电增容、改扩建，占用出线间隔
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="addUpdateOccupy" name="addUpdateOccupy" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>高可靠性供电费--收取标准
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="hFeeStandard" name="hFeeStandard" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>高可靠性供电费--收取容量
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="hCollectionCapacity" name="hCollectionCapacity" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>高可靠性供电费--应收金额
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="hAmountReceivable" name="hAmountReceivable" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>高可靠性供电费--收取依据
                </label>
                <div class="layui-input-inline">
                    <input type="text"  lay-verify="required" value="依照高可靠性供电费文件收取"
                           autocomplete="off" class="layui-input" disabled >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>勘查人员
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="explorers" name="explorers" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input"  >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>附件图片
                </label>
                <div class="layui-input-inline">
                    <img class="layui-upload-img" src="" id="imgUrl" width="100px" /><br><br><br>
                    <input type="hidden" id="enclosureFile" name="enclosureFile"  >
                    <button type="button" class="layui-btn" id="upload">
                        <i class="layui-icon">&#xe67c;</i>上传文件
                    </button><script>
                    updateFile("upload","imgUrl","enclosureFile");
                    </script>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>供电方案简图
                </label>
                <div class="layui-input-inline">
                    <img class="layui-upload-img" src="" id="imgUrl2" width="100px" /><br><br><br>
                    <input type="hidden" id="powerSupplyDiagram" name="powerSupplyDiagram"  >
                    <button type="button" class="layui-btn" id="upload2">
                        <i class="layui-icon">&#xe67c;</i>上传文件
                    </button><script>
                    updateFile("upload2","imgUrl2","powerSupplyDiagram");
                </script>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>最终版供电方案上传
                </label>
                <div class="layui-input-inline">
                    <img class="layui-upload-img" src="" id="imgUrl3" width="100px" /><br><br><br>
                    <input type="hidden" id="powerSupplyFinal" name="powerSupplyFinal"  >
                    <button type="button" class="layui-btn" id="upload3">
                        <i class="layui-icon">&#xe67c;</i>上传文件
                    </button><script>
                    updateFile("upload3","imgUrl3","powerSupplyFinal");
                </script>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="preservation" type=button codeTyle="1" lay-submit="">
                    保存
                </button>
                <button  class="layui-btn" lay-filter="preAdd" type=button codeTyle="2" lay-submit="">
                    预提交
                </button>
                <button  class="layui-btn" lay-filter="add" type=button codeTyle="3" lay-submit="">
                    提交
                </button>
            </div>
      </form>
    </div>
    <script>

        $(function(){
            getProTime($("#idxProAdmin").val(),20);


            ajaxFun('get','/pc/project/getProjectBaseInfo',{"idProAdmin":$("#idxProAdmin").val()},function(data){
                if(data.code != 0){
                    alertFun(data);
                }else{
                    $("#customerName").val(data.data.customerName);
                    $("#customerAddress").val(data.data.customerProvinces+""+
                        data.data.customerCities+""+data.data.customerCounties+""+data.data.customerAddress);
                    $("#longitude").val(data.data.longitude);
                    $("#latitude").val(data.data.latitude);
                    $("#altitude").val(data.data.altitude);

                    $("#electricTotalCapacity").val(data.data.electricTotalCapacity);
                    $("#customerContacts").val(data.data.customerContacts);
                    $("#customerPhone").val(data.data.customerPhone);
                }
            })
        })

        layui.use(['form','layer'], function() {
            $ = layui.jquery;
            var form = layui.form
                , layer = layui.layer, layedit = layui.layedit;

            //自定义验证规则
            form.verify({
                otherReq: function(value,item){
                    var $ = layui.$;
                    var verifyName=$(item).attr('name')
                        , verifyType=$(item).attr('type')
                        ,formElem=$(item).parents('.layui-form')//获取当前所在的form元素，如果存在的话
                        ,verifyElem=formElem.find('input[name='+verifyName+']')//获取需要校验的元素
                        ,isTrue= verifyElem.is(':checked')//是否命中校验
                        ,focusElem = verifyElem.next().find('i.layui-icon');//焦点元素
                    if(!isTrue || !value) {
                        //定位焦点
                        focusElem.css(verifyType == 'radio' ? {"color": "#FF5722"} : {"border-color": "#FF5722"});
                        //对非输入框设置焦点
                        focusElem.first().attr("tabIndex", "1").css("outline", "0").blur(function () {
                            focusElem.css(verifyType == 'radio' ? {"color": ""} : {"border-color": ""});
                        }).focus();
                        return '必填项不能为空';
                    }
                }
            });

            form.on('radio(isDesign)', function (data) {
                $("input[name='isDesign']").val(data.value);
            })

            //监听提交
            form.on('submit(add)', function (t) {
                addSubmit(3);
            });

            //监听保存
            form.on('submit(preservation)', function (t) {
                addSubmit(1);
            });

            //监听预提交
            form.on('submit(preAdd)', function (t) {
                addSubmit(2);
            });

        });

        function addSubmit(submitState){
            var params = {
                //tcaDescribe : layui.layedit.getContent(index),
                "idProAdmin": $("#idxProAdmin").val(),
                "workOrderNumber": $("#workOrderNumber").val(),

                "programmeType": $("#programmeType").val(),
                "customerType": $("#customerType").val(),
                "customerLevel": $("#customerLevel").val(),
                "loadType": $("#loadType").val(),
                "industryType": $("#industryType").val(),
                "powerSupplyVoltage": $("#powerSupplyVoltage").val(),
                "layingLines": $("#layingLines").val(),
                "engineeringType": $("#engineeringType").val(),
                "electricityType": $("#electricityType").val(),
                "meteringType": $("#meteringType").val(),
                "calculationLoss": $("#calculationLoss").val(),
                "calculationLineLoss": $("#calculationLineLoss").val(),
                "productionControl": $("#productionControl").val(),
                "operatingUnit": $("#operatingUnit").val(),
                "addUpdateOccupy": $("#addUpdateOccupy").val(),
                "hfeeStandard": $("#hFeeStandard").val(),
                "hcollectionCapacity": $("#hCollectionCapacity").val(),
                "hamountReceivable": $("#hAmountReceivable").val(),
                "explorers": $("#explorers").val(),
                "enclosureFile": $("#enclosureFile").val(),
                "powerSupplyDiagram": $("#powerSupplyDiagram").val(),
                "powerSupplyFinal": $("#powerSupplyFinal").val(),

                "isDesign": $("input[name='isDesign']").val(),

                "submitState":submitState
            }
            console.log(params);
            debugger
            if (true) {
                ajaxFunJson('post','/pc/project/addPowerSupplyScheme',JSON.stringify(params),function(data){
                    if (data.code != 0) {
                        alertFun(data);
                    } else {
                        window.location.href = path + "/modules/project/onePro/zdgdfa/list.html";
                        console.log("success !");
                    }
                })
                return false;
            }
        }
    </script></body></html>